//
//  GHtitleBtn.m
//  12-guhu_weibo
//
//  Created by GHapple on 15-1-31.
//  Copyright (c) 2015年 itcast. All rights reserved.
//

#import "GHtitleBtn.h"

@implementation GHtitleBtn

- (id)initWithCoder:(NSCoder *)aDecoder{
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self settitle];
    }
    return self;

}
- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        [self settitle];
    }
    return self;
}
- (void)settitle{
    
    // 进行一次性的初始化
    [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    // 图片和文字居中
    self.imageView.contentMode = UIViewContentModeCenter;
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
}

- (void)layoutSubviews{


    [super layoutSubviews];
    //设置文字和图片的位置
    self.titleLabel.x = self.imageView.x;
    self.imageView.x = CGRectGetMaxX(self.titleLabel.frame) +5;


}
@end
